package com.thread;

/**
 * @Author WaveHi
 * @Date 18/8/2021 下午 5:31
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Test the state of task
 */
public class TestThreadUp {

    public static void main(String[] args) {

        //获取线程
        Thread th1 = new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                for (int i = 0; i < 1000; i++) {

                    System.out.println("I am Tom");

                }

            }
        }, "Tom");
        Thread th2 = new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                for (int i = 0; i < 1000; i++) {

                    System.out.println("I am John");

                }

            }
        }, "John");
        Thread th3 = new Thread(new Runnable() {
            @Override
            public void run() {

                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                for (int i = 0; i < 1000; i++) {

                    System.out.println("I am Marry");

                }

            }
        }, "Marry");


        //测试yield方法
        th1.start();
        th2.start();
        th1.yield();
        th3.start();

        //测试join方法

    }

}
